using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.equip
{
[System.Serializable]
public  class EquipWeapon : Equip
 {

    public cfg.equip.EWeaponType weaponType ;
     public string model  = "";
     public string bones  = "";
     public int skillNormal ;
     


    public const int TYPE_ID = 602505860;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(21);
        os.WriteSize(Tag.INT | (1 << Tag.TAG_SHIFT));  os.WriteInt(id);  
         os.WriteSize(Tag.STRING | (2 << Tag.TAG_SHIFT));  os.WriteString(name);  
         os.WriteSize(Tag.INT | (3 << Tag.TAG_SHIFT));  os.WriteInt((int)equipType);  
         os.WriteSize(Tag.STRING | (4 << Tag.TAG_SHIFT));  os.WriteString(equipTypeName);  
         os.WriteSize(Tag.STRING | (5 << Tag.TAG_SHIFT));  os.WriteString(displayItemType);  
         os.WriteSize(Tag.STRING | (6 << Tag.TAG_SHIFT));  os.WriteString(icon);  
         os.WriteSize(Tag.INT | (7 << Tag.TAG_SHIFT));  os.WriteInt((int)quality);  
         os.WriteSize(Tag.INT | (8 << Tag.TAG_SHIFT));  os.WriteInt(prize);  
         os.WriteSize(Tag.BEAN | (9 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_condition_Gender(gender,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.STRING | (10 << Tag.TAG_SHIFT));  os.WriteString(introduction);  
         os.WriteSize(Tag.BEAN | (11 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_condition_MinMaxLevel(levelLimit,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.INT | (12 << Tag.TAG_SHIFT));  os.WriteInt(maxPile);  
         os.WriteSize(Tag.BOOL | (13 << Tag.TAG_SHIFT));  os.WriteBool(canSell);  
         os.WriteSize(Tag.LIST | (14 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_fight_AttrArea(attrArea,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.INT | (15 << Tag.TAG_SHIFT));  os.WriteInt((int)part);  
         os.WriteSize(Tag.STRING | (16 << Tag.TAG_SHIFT));  os.WriteString(displayPart);  
         os.WriteSize(Tag.INT | (17 << Tag.TAG_SHIFT));  os.WriteInt(durable);  
         os.WriteSize(Tag.INT | (18 << Tag.TAG_SHIFT));  os.WriteInt((int)weaponType);  
         os.WriteSize(Tag.STRING | (19 << Tag.TAG_SHIFT));  os.WriteString(model);  
         os.WriteSize(Tag.STRING | (20 << Tag.TAG_SHIFT));  os.WriteString(bones);  
         os.WriteSize(Tag.INT | (21 << Tag.TAG_SHIFT));  os.WriteInt(skillNormal);  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.INT | (1 << Tag.TAG_SHIFT)):   id = os.ReadInt(); break;  
             case (Tag.STRING | (2 << Tag.TAG_SHIFT)):   name = os.ReadString(); break;  
             case (Tag.INT | (3 << Tag.TAG_SHIFT)):   equipType = (cfg.equip.EEquipType)(os.ReadInt()); break;  
             case (Tag.STRING | (4 << Tag.TAG_SHIFT)):   equipTypeName = os.ReadString(); break;  
             case (Tag.STRING | (5 << Tag.TAG_SHIFT)):   displayItemType = os.ReadString(); break;  
             case (Tag.STRING | (6 << Tag.TAG_SHIFT)):   icon = os.ReadString(); break;  
             case (Tag.INT | (7 << Tag.TAG_SHIFT)):   quality = (cfg.item.EItemColor)(os.ReadInt()); break;  
             case (Tag.INT | (8 << Tag.TAG_SHIFT)):   prize = os.ReadInt(); break;  
             case (Tag.BEAN | (9 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); gender = cfg.Extensions.unmarshal_compatible_cfg_condition_Gender(os); os = _oldOs; break; }   
             case (Tag.STRING | (10 << Tag.TAG_SHIFT)):   introduction = os.ReadString(); break;  
             case (Tag.BEAN | (11 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); levelLimit = cfg.Extensions.unmarshal_compatible_cfg_condition_MinMaxLevel(os); os = _oldOs; break; }   
             case (Tag.INT | (12 << Tag.TAG_SHIFT)):   maxPile = os.ReadInt(); break;  
             case (Tag.BOOL | (13 << Tag.TAG_SHIFT)):   canSell = os.ReadBool(); break;  
             case (Tag.LIST | (14 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); attrArea = cfg.Extensions.unmarshal_compatible_list_cfg_fight_AttrArea(os); os = _oldOs; break; }   
             case (Tag.INT | (15 << Tag.TAG_SHIFT)):   part = (cfg.equip.EEquipPart)(os.ReadInt()); break;  
             case (Tag.STRING | (16 << Tag.TAG_SHIFT)):   displayPart = os.ReadString(); break;  
             case (Tag.INT | (17 << Tag.TAG_SHIFT)):   durable = os.ReadInt(); break;  
             case (Tag.INT | (18 << Tag.TAG_SHIFT)):   weaponType = (cfg.equip.EWeaponType)(os.ReadInt()); break;  
             case (Tag.STRING | (19 << Tag.TAG_SHIFT)):   model = os.ReadString(); break;  
             case (Tag.STRING | (20 << Tag.TAG_SHIFT)):   bones = os.ReadString(); break;  
             case (Tag.INT | (21 << Tag.TAG_SHIFT)):   skillNormal = os.ReadInt(); break;  
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "EquipWeapon");
        ele.WriteStartElement("id"); ele.WriteAttributeString("id", "1"); ele.WriteInt(id); ele.WriteEndElement();
         ele.WriteStartElement("name"); ele.WriteAttributeString("id", "2"); ele.WriteString2(name); ele.WriteEndElement();
         ele.WriteStartElement("equipType"); ele.WriteAttributeString("id", "3"); ele.WriteEnum(equipType); ele.WriteEndElement();
         ele.WriteStartElement("equipTypeName"); ele.WriteAttributeString("id", "4"); ele.WriteString2(equipTypeName); ele.WriteEndElement();
         ele.WriteStartElement("displayItemType"); ele.WriteAttributeString("id", "5"); ele.WriteString2(displayItemType); ele.WriteEndElement();
         ele.WriteStartElement("icon"); ele.WriteAttributeString("id", "6"); ele.WriteString2(icon); ele.WriteEndElement();
         ele.WriteStartElement("quality"); ele.WriteAttributeString("id", "7"); ele.WriteEnum(quality); ele.WriteEndElement();
         ele.WriteStartElement("prize"); ele.WriteAttributeString("id", "8"); ele.WriteInt(prize); ele.WriteEndElement();
         ele.WriteStartElement("gender"); ele.WriteAttributeString("id", "9"); cfg.Extensions.xml_marshal_cfg_condition_Gender(gender,ele); ele.WriteEndElement();
         ele.WriteStartElement("introduction"); ele.WriteAttributeString("id", "10"); ele.WriteString2(introduction); ele.WriteEndElement();
         ele.WriteStartElement("levelLimit"); ele.WriteAttributeString("id", "11"); cfg.Extensions.xml_marshal_cfg_condition_MinMaxLevel(levelLimit,ele); ele.WriteEndElement();
         ele.WriteStartElement("maxPile"); ele.WriteAttributeString("id", "12"); ele.WriteInt(maxPile); ele.WriteEndElement();
         ele.WriteStartElement("canSell"); ele.WriteAttributeString("id", "13"); ele.WriteBool(canSell); ele.WriteEndElement();
         ele.WriteStartElement("attrArea"); ele.WriteAttributeString("id", "14"); cfg.Extensions.xml_marshal_list_cfg_fight_AttrArea(attrArea,ele); ele.WriteEndElement();
         ele.WriteStartElement("part"); ele.WriteAttributeString("id", "15"); ele.WriteEnum(part); ele.WriteEndElement();
         ele.WriteStartElement("displayPart"); ele.WriteAttributeString("id", "16"); ele.WriteString2(displayPart); ele.WriteEndElement();
         ele.WriteStartElement("durable"); ele.WriteAttributeString("id", "17"); ele.WriteInt(durable); ele.WriteEndElement();
         ele.WriteStartElement("weaponType"); ele.WriteAttributeString("id", "18"); ele.WriteEnum(weaponType); ele.WriteEndElement();
         ele.WriteStartElement("model"); ele.WriteAttributeString("id", "19"); ele.WriteString2(model); ele.WriteEndElement();
         ele.WriteStartElement("bones"); ele.WriteAttributeString("id", "20"); ele.WriteString2(bones); ele.WriteEndElement();
         ele.WriteStartElement("skillNormal"); ele.WriteAttributeString("id", "21"); ele.WriteInt(skillNormal); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  id = ele.ReadInt(); break; 
                 case 2:  name = ele.ReadString2(); break; 
                 case 3:  equipType = ele.ReadEnum<cfg.equip.EEquipType>(); break; 
                 case 4:  equipTypeName = ele.ReadString2(); break; 
                 case 5:  displayItemType = ele.ReadString2(); break; 
                 case 6:  icon = ele.ReadString2(); break; 
                 case 7:  quality = ele.ReadEnum<cfg.item.EItemColor>(); break; 
                 case 8:  prize = ele.ReadInt(); break; 
                 case 9:  gender = cfg.Extensions.xml_unmarshal_cfg_condition_Gender(ele); break; 
                 case 10:  introduction = ele.ReadString2(); break; 
                 case 11:  levelLimit = cfg.Extensions.xml_unmarshal_cfg_condition_MinMaxLevel(ele); break; 
                 case 12:  maxPile = ele.ReadInt(); break; 
                 case 13:  canSell = ele.ReadBool(); break; 
                 case 14:  attrArea = cfg.Extensions.xml_unmarshal_list_cfg_fight_AttrArea(ele); break; 
                 case 15:  part = ele.ReadEnum<cfg.equip.EEquipPart>(); break; 
                 case 16:  displayPart = ele.ReadString2(); break; 
                 case 17:  durable = ele.ReadInt(); break; 
                 case 18:  weaponType = ele.ReadEnum<cfg.equip.EWeaponType>(); break; 
                 case 19:  model = ele.ReadString2(); break; 
                 case 20:  bones = ele.ReadString2(); break; 
                 case 21:  skillNormal = ele.ReadInt(); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "id":  id = ele.ReadInt(); break; 
                 case "name":  name = ele.ReadString2(); break; 
                 case "equip_type":  equipType = ele.ReadEnum<cfg.equip.EEquipType>(); break; 
                 case "equip_type_name":  equipTypeName = ele.ReadString2(); break; 
                 case "display_item_type":  displayItemType = ele.ReadString2(); break; 
                 case "icon":  icon = ele.ReadString2(); break; 
                 case "quality":  quality = ele.ReadEnum<cfg.item.EItemColor>(); break; 
                 case "prize":  prize = ele.ReadInt(); break; 
                 case "gender":  gender = cfg.Extensions.xml_unmarshal_cfg_condition_Gender(ele); break; 
                 case "introduction":  introduction = ele.ReadString2(); break; 
                 case "level_limit":  levelLimit = cfg.Extensions.xml_unmarshal_cfg_condition_MinMaxLevel(ele); break; 
                 case "max_pile":  maxPile = ele.ReadInt(); break; 
                 case "can_sell":  canSell = ele.ReadBool(); break; 
                 case "attr_area":  attrArea = cfg.Extensions.xml_unmarshal_list_cfg_fight_AttrArea(ele); break; 
                 case "part":  part = ele.ReadEnum<cfg.equip.EEquipPart>(); break; 
                 case "display_part":  displayPart = ele.ReadString2(); break; 
                 case "durable":  durable = ele.ReadInt(); break; 
                 case "weapon_type":  weaponType = ele.ReadEnum<cfg.equip.EWeaponType>(); break; 
                 case "model":  model = ele.ReadString2(); break; 
                 case "bones":  bones = ele.ReadString2(); break; 
                 case "skill_normal":  skillNormal = ele.ReadInt(); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
